// created by jimmy 2016/3/1
/*获取手机验证码*/
function getSmsCode(object, phone , code, type, callback) {
    $.nmDebug.log("getSmsCode---", "getSmsCode");
    hideErrorTips(object.parent().find(".errorCodeTips"));
    $.ajax({
        type: "get",
        async: true, //异步请求
        url: '/user/smsCode?random=' + Math.random(),
        data: {
            phone: phone,
            type: type,
            code: code
        },
        timeout: 3000,
        success: function(datas) {
            $.nmDebug.log("datas---", datas);
            if (datas.status == 0000) {
                setCodeTimer(object);
            } else {
                callback(datas);
            }

        },
        error: function() {
            $.nmDebug.log("失败，请稍后再试！");
        }
    });
}

/*检查手机号接口*/
function checkPhoneReq(obj, callback) {
    var phone = obj.prop("value");
    $.ajax({
        type: "get",
        async: true, //异步请求
        url: '/user/checkPhone?random=' + Math.random(),
        data: {
            phone: phone
        },
        timeout: 3000,
        success: function(datas) {
            $.nmDebug.log(datas);
            callback(obj, datas);
        },
        error: function() {
            $.nmDebug.log("失败，请稍后再试！");
        }
    });
}

/*显示错误提示*/
function showErrorTips(object, text) {
    object.removeClass("hide");
    if (text != null && text.length > 0)
        object.find("p").text(text);
}
/*隐藏错误提示*/
function hideErrorTips(object) {
    object.addClass("hide");
}

/*显示错误提示*/
function showErrorTipsByAn(object, text) {
    object.removeClass("hide");
    if (text != null && text.length > 0)
        object.find("p").text(text);
    object.fadeIn(1000, function() {
        object.fadeOut(1000, function() {
            object.addClass("hide");
        });
    });
}
